<template>

  <div>
    <el-form :inline="true" :model="queryParams" class="demo-form-inline">

      <el-form-item label="申请类型">
        <el-select v-model="queryParams.jrProductType" placeholder="请选择">
          <el-option label="租房分期" value="1"></el-option>
          <el-option label="收房贷" value="2"></el-option>
          <el-option label="应收租约保理" value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="申请状态">
        <el-select v-model="queryParams.applyState" placeholder="请选择">
          <el-option label="申请中" value="1"></el-option>
          <el-option label="初审通过(待复审)" value="2"></el-option>
          <el-option label="初审不通过" value="3"></el-option>
          <el-option label="复审通过" value="4"></el-option>
          <el-option label="复审不通过" value="5"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="起租日期">
        <div class="block">
          <el-date-picker v-model="queryParams.startDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">

          </el-date-picker>至
          <el-date-picker v-model="queryParams.endDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
          </el-date-picker>
        </div>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>

    </el-form>
    <el-table   :data="financelist">
      <el-table-column label="申请合同号" prop="applyOrderNo" width="120" />
      <el-table-column label="贷款信息" prop="loanMessage" width="120" />
      <el-table-column label="申请类型" width="300">
        <template slot-scope="scope">
          <div v-if="scope.row.jrProductType==1">
            租房分期
          </div>
          <div v-else-if="scope.row.jrProductType==2">
            收房贷
          </div>
          <div v-else>
            应收租约保理
          </div>
        </template>
      </el-table-column>
      <el-table-column label="借款金额" width="150">
        <template slot-scope="scope">
          {{ scope.row.loanAmount }}元
        </template>
      </el-table-column>
      <el-table-column label="借款期限" width="150">
        <template slot-scope="scope">
          {{ scope.row.monthLimit }}月
        </template>
      </el-table-column>
      <el-table-column label="申请日期" prop="createTime" width="120" />
      <el-table-column label="资金方" prop="companyName" width="120" />
      <el-table-column label="申请状态" width="300">
        <template slot-scope="scope">
          <div v-if="scope.row.applyState==1">
            申请中
          </div>
          <div v-else-if="scope.row.applyState==2">
            初审通过(待复审)
          </div>
          <div v-else-if="scope.row.applyState==3">
            初审不通过
          </div>
          <div v-else-if="scope.row.applyState==4">
            复审通过
          </div>
          <div v-else>
            复审不通过
          </div>
        </template>
      </el-table-column>

      <el-table-column label=驳回原因 prop="auditMemo" width="120" />
      <el-table-column label="操作" width="300">
        <template slot-scope="scope">
          <div v-if="scope.row.applyState==1">
            <el-button @click="shenhe(scope.row)" type="text" size="small">审核</el-button>
          </div>
          <div v-else-if="scope.row.applyState==2">
            <el-button @click="shenhe(scope.row)" type="text" size="small">审核</el-button>
          </div>
          <div v-else-if="scope.row.applyState==3">
            <el-button @click="cha(scope.row)" type="text" size="small">查看</el-button>

          </div>
          <div v-else-if="scope.row.applyState==4">
            <el-button @click="cha(scope.row)" type="text" size="small">查看</el-button>
          </div>
          <div v-else-if="scope.row.applyState==5">

            <el-button @click="cha(scope.row)" type="text" size="small">查看</el-button>
          </div>
          <div v-else-if="scope.row.applyState==6">
            放款成功
          </div>
          <div v-else-if="scope.row.applyState==7">
            已成功
          </div>
          <div v-else-if="scope.row.applyState==8">
            已违约
          </div>
          <div v-else>
            审核中
          </div>
        </template>
      </el-table-column>


    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    ></pagination>
    <!--    查看-->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible1"
      width="80%">
      <h1>|申请主题信息</h1><br>
      公寓名称：{{zf.premiseName}}<br><br>
      公司名称：{{zf.premiseName}}
      联系人：{{zf.premiseName}}<br><br>
      手机号：{{contas.signUserMobile}}
      申请时间：{{zf.createTime}}<br><br>
      法人姓名：{{contas.signUserName}}
      法人身份证：{{contas.signUserIdCard}}<br><br>
      公司地址：{{contas.cqAddress}}
      账户类型：<br><br>
      账户：
      开户行：<br>
      法人身份证：
      <h1>|贷款详细信息</h1><br>
      租客姓名：{{zf.tenantName}}
      租客身份证号：{{zf.tenantCardNo}}<br><br>
      租客手机号：{{zf.tenantPhone}}
      承租房间：{{zf.roomName}}<br><br>
      月租金：{{zf.monthRent}}元
      押金：{{zf.deposit}}元<br><br>
      租约起始日期：{{zf.startDate}}
      租约终止日期：{{zf.endDate}}<br><br>
      还款周期：1个月
      还款账期：月<br><br>
      服务费：
      利息：{{zhuti.monthLimit}}元<br><br>
      待收租金合计<br><br>
      租房合同<br><br>

      租客身份证：<br><br>
      <el-button v-if="sf==2" @click="tong">审核通过</el-button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <el-button v-if="sf==2" @click="bu">审核不通过</el-button>
      <span slot="footer" class="dialog-footer">
    <el-button @click="qx">取 消</el-button>
    <el-button type="primary" @click="qd">确 定</el-button>
  </span>
    </el-dialog>
    <!--    收房贷-->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="80%">
      <h1>|申请主题信息</h1><br>
      公寓名称：{{contas.premiseName}}<br><br>
      公司名称：{{contas.premiseName}}
      联系人：{{contas.premiseName}}<br><br>
      手机号：{{contas.signUserMobile}}
      申请时间：{{contas.conSignTime}}<br><br>
      法人姓名：{{contas.signUserName}}
      法人身份证：{{contas.signUserIdCard}}<br><br>
      公司地址：{{contas.cqAddress}}
      账户类型：{{contas.accountType}}<br><br>
      账户：{{contas.bankCardNumber}}
      开户行：{{contas.bankOpen}}<br>
      法人身份证：
      <h1>|贷款详细信息</h1><br>
      业主姓名：{{contas.ownerName}}
      业主身份证号：{{contas.ownerIdCard}}<br><br>
      业主手机号：{{contas.ownerMobile}}
      业主银行卡号：{{contas.bankCard}}<br><br>
      业主开户行：{{contas.bankOpen}}<br><br>
      借款金额：{{zhuti.loanAmount}}元
      贷款利息：{{zhuti.reserve1}}元<br><br>
      一次性服务费：{{zhuti.reserve1}}元
      还款周期：1个月<br><br>
      租约起始日期：{{contas.leaseStartTime}}
      租约终止日期：{{contas.leaseEndTime}}<br><br>
      周期还款金额：{{zhuti.monthLimit}}元
      还款账期：{{zhuti.monthLimit}}月<br><br>
      房产证：<br><br>
      租房合同：<br><br>
      业主身份证：<br><br>
      业主银行卡：<br><br>
      维数公寓收取服务费:
      <el-input label="维数公寓收取服务费" style="width: 150px" v-if="sf==1"></el-input>
      <br><br>
      <el-button v-if="sf==2" @click="tong">审核通过</el-button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <el-button v-if="sf==2" @click="bu">审核不通过</el-button>
      <span slot="footer" class="dialog-footer">
    <el-button @click="qx2">取 消</el-button>
    <el-button type="primary" @click="qd2">确定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
  import {listFinan,getObject,getContract,updateLoan} from "../../../api/banking/finance";

  export default {
    name: "index",
    data() {
      return {
        financelist: [],
        queryParams: {
          pageNum: 1,
          pageSize: 10,

        },
        total: 0,
        zf: {},
        dialogVisible1: false,
        //收房贷审核
        sf: 1,
        dialogVisible: false,
        contas: {},
        zhuti: {},
      }
    },
    created() {
      this.getList();


    },
    methods: {
      /** 查询租客列表 */
      getList() {
        listFinan(this.addDateRange(this.queryParams)).then(
          response => {
            this.financelist = response.rows;
            this.total = response.total;
          }
        );
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      cha(row) {
        if (row.jrProductType == 2) {
          getObject(row).then(response => {
            this.zhuti = response.data;
            this.dialogVisible = true;

          });
        } else if (row.jrProductType == 1) {
          getContract(row.cfContractId).then(response => {
            this.zf = response.data;
            this.dialogVisible1 = true;

          });
        }
      },
      //审核
      shenhe(row) {
        this.shenhes = row;
        this.cha(row);
        this.sf = 2;
        this.pd = row.jrProductType;

      },
      tong() {
        //.
        // console.log(this.shenhes);
        //if(this.pd==2){
        this.shenhes.applyState = 2;
        updateLoan(this.shenhes).then(response => {
          console.log("审核：" + response)
          this.sf = 1
          this.dialogVisible = false;
          // alert(response.rows);
        })
        //}


      },
      bu() {
        //if(this.pd==2){
        this.shenhes.applyState = 3;
        updateLoan(this.shenhes).then(response => {
          console.log("审核：" + res)
          this.sf = 1
          this.dialogVisible = false;
          // alert(response.rows);
        })
      }
    }
  }


</script>

<style scoped>

</style>
